/**
 * Created:	2001-7-
 * By:		eeorange
 * About: 	uva 729 - The Hamming Distance Problem
 * Status:	AC 332ms
 */

#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <algorithm>

using namespace std;

#define MAXN		1000


void print_permutation(int n, int* P, int* A, int cur){
	if(cur == n){
		for(int i=0; i<n; i++) printf("%d", A[i]);
		printf("\n");
	}
	else for(int i=0; i<n; i++) if(!i || P[i] != P[i-1]) // permutation all
	{
		int v = P[i];
		int c1 = 0, c2 = 0;
		for(int j=0; j<cur; j++) if(A[j] == v) c1++;
		for(int j=0; j<n; j++) if(P[j] == v) c2++;
		if(c1 < c2){
			A[cur] = v;
			print_permutation(n, P, A, cur+1);
		}
	}
}

int main(){
	int nr_cases;
	scanf("%d", &nr_cases);
	int first = 1;
	while(nr_cases--){
		if(first) first = 0;
		else printf("\n");
		int P[20], A[20];
		int n, h;
		scanf("%d%d", &n, &h);
		for(int i=0; i<n; i++) P[i] = i<n-h ? 0 : 1;
		print_permutation(n, P, A, 0);
	}

	return 0;
}


